<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2024/4/23
 * Time: 15:19
 */

namespace app\logic\index\help;


use app\logic\BaseLogic;

class EditorHelpLogic extends BaseLogic
{
    protected $model;

    protected static $instance;

    public function __construct()
    {
        parent::__construct();
        $this->model = \app\model\help\EditorHelpModel::getInstance();
    }

    public static function getInstance()
    {
//        if(is_object(self::$instance)){
//            return self::$instance;
//        }

        return  new self();
    }

    public function getList($param)
    {
        $where = [
            'isdel'=>0,
            'status'=>1,
        ];
        if(!empty($param['category_id'])){
            $where['category_id'] = $param['category_id'];
        }
        $fields = ['id','title','content','category_id'];
        $order = ['sort', 'asc'];

        $list =  $this->model->index($where, $fields, $order);

        return $list;
    }

    public function getDetail($param)
    {
        $where = [
            'isdel'=>0,
        ];
        if(!empty($param['id'])){
            $where['id'] = $param['id'];
        }
        if(!empty($param['title'])){
            $where['title'] = $param['title'];
        }
        if(!empty($param['category_id'])){
            $where['category_id'] = $param['category_id'];
        }

        $fields = ['id','title','content','category_id','status'];

        $first =  $this->model->getWhere($where)->first($fields);

        return $first;
    }
}